<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        const api_news = `http://ajax-api.itheima.net/api/news`
        fetch(api_news)
            .then(res => res.json())
            .then(res => {
                console.log(res)
            })
            .catch(err => {
                console.log(err)
            })

        const api_login = `http://ajax-api.itheima.net/api/login`
        const params = { username: 'admin', password: '123456' }
        fetch(api_login, {
            method: 'POST',
            headers: {
                'content-type': 'application/json'
            },
            body: JSON.stringify(params)
        })
            .then(res => res.json())
            .then(res => console.log(res))
    </script>
</body>

</html>